package com.lgmshare.component.utils;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import java.util.ArrayList;

public class ZUtils {

    /**
     * 分享功能-调用系统分享功能
     *
     * @param context    上下文
     * @param shareTitle 分享弹窗标题
     * @param msgTitle   消息标题
     * @param msgText    消息内容
     */
    public static void shareText(Context context, String shareTitle, String msgTitle, String msgText) {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
        intent.putExtra(Intent.EXTRA_TEXT, msgText);
        context.startActivity(Intent.createChooser(intent, shareTitle));
    }

    /**
     * 分享功能-调用系统分享功能
     *
     * @param context    上下文
     * @param shareTitle 分享弹窗标题
     * @param uri        图片
     */
    public static void shareImage(Context context, String shareTitle, Uri uri) {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("image/*");
        intent.putExtra(Intent.EXTRA_STREAM, uri);
        context.startActivity(Intent.createChooser(intent, shareTitle));
    }

    public static void shareImages(Context context, String shareTitle, ArrayList<Uri> uris) {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND_MULTIPLE);
        intent.setType("image/*");
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        context.startActivity(Intent.createChooser(intent, shareTitle));
    }

    public static void shareFile(Context context, String shareTitle, String mimeType, Uri uri) {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.setType(mimeType);
        intent.putExtra(Intent.EXTRA_STREAM, uri);
        context.startActivity(Intent.createChooser(intent, shareTitle));
    }

    public static void shareFiles(Context context, String shareTitle, String mimeType, ArrayList<Uri> uris) {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND_MULTIPLE);
        intent.setType(mimeType);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        context.startActivity(Intent.createChooser(intent, shareTitle));
    }

}
